from pyecharts import options as opts
from pyecharts.charts import Kline
from pyecharts.options import AxisOpts, SplitAreaOpts, AreaStyleOpts

from partial__01 import create_connect
data = []

conn=create_connect(database='viz')
try:
    with conn.cursor() as cursor:
        cursor.execute(
            'select date(`Date`) as `TxDate`from tb_stock order by `Date` limit10'
        )
        x_data = [row[0] for row in cursor.fetchall()]
        print(x_data)
        cursor.execute(
            'select date(`Date`) as `TxDate`,round( `Open`,2),'
            'round( `Close`,2),  round(`Low`,2), round(`High`,2)'
            'from tb_stock order by `Date`'
        )
        y_data = cursor.fetchall()
        Kline_chart =Kline()
        Kline_chart.set_global_opts(
            yaxis_opts=AxisOpts(
                splitarea_opts=SplitAreaOpts(
                    is_show=True, areastyle_opts=AreaStyleOpts(opacity= 1)
            )
        ))
        Kline_chart.render()
finally:
    conn.close()